<template>
  <div class="mod-config">
    <basic-container>
      <navigationHeTong
        :sign="{ a: false, b: false, c: true, d: false, e: false, f: false }"
      ></navigationHeTong>
      <div class="boxsty zhiBiao">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="120px"
            >
              <el-form-item label="任务书名称">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.workAssignName"
                  placeholder="任务书名称"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人姓名">
                <el-input
                  v-model="dataForm.ryName"
                  placeholder="被考核人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>

              <el-form-item label="被考核人岗位">
                <el-input
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人职级">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.userZj"
                  placeholder="被考核人职级"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList()"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="avue-crud">
          <div style="border-top: 1px solid #b0bde2">
            <div class="mt10">
              <div style="float: right;margin-bottom: 10px">
                <el-button plain type="primary" @click="agree()"  v-loading.fullscreen.lock="fullscreenLoading">同意</el-button>
                <el-button plain type="primary" @click="backall()"  v-loading.fullscreen.lock="fullscreenLoading"
                  >驳回</el-button
                >
              </div>
            </div>
          </div>
          <el-table
            ref="table"
            style="width: 100%;"
            :data="dataList"
            border
            v-loading="dataListLoading"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="80"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="workAssignName"
              header-align="center"
              align="center"
              width="160"
              show-overflow-tooltip
              label="任务书名称"
            >
              <template slot-scope="scope">
                <span
                  @click="editBtn(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.workAssignName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              prop="userName"
              header-align="center"
              align="center"
              min-width="150"
              label="被考核人编号"
            >
            </el-table-column>
            <el-table-column
              prop="ryName"
              header-align="center"
              align="center"
              min-width="150"
              label="被考核人姓名"
            >
            </el-table-column>
            <el-table-column
              prop="userDeptName"
              header-align="center"
              align="center"
              min-width="150"
              label="被考核人单位"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
              prop="userZw"
              header-align="center"
              align="center"
              min-width="170"
              label="被考核人岗位"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
              prop="userZj"
              header-align="center"
              align="center"
              min-width="170"
              label="被考核人职级"
            >
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <commomDialog ref="commomDialog" @editChildren="getDataList"></commomDialog>
    </basic-container>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { pageByzbsh,okAllApish,backAllApish } from "@/api/hetongrenwu/book/bookSh";
import commomDialog from '../commomDialog'
export default {
  components: {
      commomDialog
  },
  data() {
    return {
      dataForm: {
      },
      ids: [],
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      searchadvanced: true,
      searchheight: "0",
      fullscreenLoading:false,
    };
  },
  watch: {
    
  },
  created() {
    this.getDataList();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    //查看
    editBtn(row) {
        this.$refs.commomDialog.init(row,'sh');
    },
    agree() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请至少选择一个合同！");
        return;
      }
      this.fullscreenLoading = true;
      okAllApish({ rows: data }).then((data) => {
        this.$message.closeAll();
        this.$message.success("审核通过！");
        this.fullscreenLoading = false;
        this.getDataList();
      });
    },
    backall() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.closeAll();
        this.$message.error("请至少选择一个合同！");
        return;
      }
      this.fullscreenLoading = true;
      backAllApish({ rows: data }).then((response) => {
        this.$message.closeAll();
        this.$message.success("驳回成功！");
        this.getDataList();
        this.fullscreenLoading = false;
      });
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      pageByzbsh(
        Object.assign({
          current: this.pageIndex,
          size: this.pageSize,
        },this.dataForm)
      )
        .then((response) => {
          this.dataList = response.data.data.records;
          this.totalPage = response.data.data.total;
          this.dataListLoading = false;
        })
        .catch((res) => {
          this.dataListLoading = false;
        });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
  },
};
</script>
